import React, { useEffect } from 'react'
import { incre, asyncIncre } from '../../store/count/countSlice'
import { useSelector, useDispatch } from 'react-redux'
export default function Redux() {
    // console.log(store.getState());
    // console.log(store.getState());
    // console.log(store, '============');

    const dispath = useDispatch()

    const value = useSelector(state => state.countSlice.value)
    const todoList = useSelector(state => state.countSlice.todolist)
    console.log(todoList, '=========');
    useEffect(() => {
        dispath(asyncIncre())
    }, [])
    return (
        <div>
            <button onClick={() => dispath(incre(1))}>+1</button>
            <button>-1</button>
            计算之后的值：{value}
            <ul>
                {
                    todoList.map((item, index) => {
                        return <li key={index}>{item.name}</li>
                    })
                }
            </ul>
        </div>
    )
}
